/*
 * Copyright (c) 2010 Philip Foulkes <philip.foulkes@gmail.com>
 *
 * This file is free software and is made available under the 
 * terms of the GNU General Public License, version 2, or at your
 * option, any later version
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 */

#ifndef _MRP_TIMER_H_
#define _MRP_TIMER_H_

u32 mrp_timer_get_random_leave_all_time (void);
u32 mrp_timer_get_random_join_time (void);

#define MRP_TIMER_VALUE_TO_JIFFIES(timer_value) ((timer_value) * HZ / 100)

/**
*   MRP timer parameter values -- these values are represented in centiseconds
*/
#define MRP_TIMER_VALUE_JOIN_TIME_MIN		0
#define MRP_TIMER_VALUE_JOIN_TIME_MAX		20
#define MRP_TIMER_VALUE_JOIN_TIME			mrp_timer_get_random_join_time ()
#define MRP_TIMER_VALUE_LEAVE_TIME_MIN		60
#define MRP_TIMER_VALUE_LEAVE_TIME_AVERAGE	80
#define MRP_TIMER_VALUE_LEAVE_TIME_MAX		100
#define MRP_TIMER_VALUE_LEAVE_ALL_TIME_MIN	1000
#define MRP_TIMER_VALUE_LEAVE_ALL_TIME_MAX	1500
#define MRP_TIMER_VALUE_LEAVE_ALL_TIME		mrp_timer_get_random_leave_all_time ()
#define MRP_TIMER_VALUE_PERIODIC_TIME		100 // 802.1ak 10.7.4.4

#define MRP_TIMER_VALUE_JOIN_TIME_JIFFIES			MRP_TIMER_VALUE_TO_JIFFIES(MRP_TIMER_VALUE_JOIN_TIME)
#define MRP_TIMER_VALUE_LEAVE_TIME_MIN_JIFFIES		MRP_TIMER_VALUE_TO_JIFFIES(MRP_TIMER_VALUE_LEAVE_TIME_MIN)
#define MRP_TIMER_VALUE_LEAVE_TIME_AVERAGE_JIFFIES 	MRP_TIMER_VALUE_TO_JIFFIES(MRP_TIMER_VALUE_LEAVE_TIME_AVERAGE)
#define MRP_TIMER_VALUE_LEAVE_TIME_MAX_JIFFIES		MRP_TIMER_VALUE_TO_JIFFIES(MRP_TIMER_VALUE_LEAVE_TIME_MAX)
#define MRP_TIMER_VALUE_LEAVE_ALL_TIME_JIFFIES		MRP_TIMER_VALUE_TO_JIFFIES(MRP_TIMER_VALUE_LEAVE_ALL_TIME)
#define MRP_TIMER_VALUE_PERIODIC_TIME_JIFFIES		MRP_TIMER_VALUE_TO_JIFFIES(MRP_TIMER_VALUE_PERIODIC_TIME)

#endif
